package com.example.wan1.adapter;

import android.content.res.ColorStateList;
import android.graphics.Color;
import android.widget.ImageView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.example.wan1.R;

import java.util.List;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

/***
 * @Author: zxd
 * @CreateDate: 2020/8/7 16:08
 * @Description:
 */
public class ThemeAdapter extends BaseQuickAdapter<String, BaseViewHolder> {
    public ThemeAdapter(int layoutResId, @Nullable List<String> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(@NonNull BaseViewHolder holder, String s) {
        //holder.setBackgroundColor(R.id.theme_item_iv, Color.parseColor(s));
        /*ImageView iv = holder.getView(R.id.theme_item_iv);
        iv.setColorFilter(Color.parseColor(s));*/
        //不行的原因是，只能针对图片的颜色，不能针对背景

        ImageView iv = holder.getView(R.id.theme_item_iv);
        iv.setBackgroundTintList(ColorStateList.valueOf(Color.parseColor(s)));
    }
}
